package org.example.test1;

public class Area {

    //静态代码块,在所在类首次加载时,自动执行一次,以后不在执行
    //不想创建对象,只想使用变量,static
    public static double pi = 3.14;

    public int h = 10;
    public static double getArea(double s) {
        return s*s*pi;
    }
    public void showArea(double r){
        System.out.println(Area.getArea(r));
        System.out.println(Area.pi);
        System.out.println(pi);
    }
    //静态方法不能直接访问实例对象的成员,必须通过对象名调用
    public static void show2() {
        Area area = new Area();
        area.showArea(2);
    }
}
